import java.sql.*;

public class testTemp {
    public static final String url = "jdbc:mysql://rm-uf6v59d4fuzneh9mpko.mysql.rds.aliyuncs.com:3306/gbtest";
    public static final String user = "shiyidata";
    public static final String passWord = "Bestage1116";
    public static final String table = "xf_package";
    //    public static final String table = "xf_test";
//    public static final String table = "test";
    public static final String endtable = "xf_pack_end10";

    public static void main(String[] args) throws SQLException {
        Connection connection = DriverManager.getConnection(url, user, passWord);
        connection.setAutoCommit(false);

        PreparedStatement pup = connection.prepareStatement("select 序号 from " + endtable +" where 运单号码 in "+ " (select distinct(运单号码) from " + endtable + " group by `运单号码` having count(*) > 1) "+" and 寄件地区 <>'上海' and 到件地区 = '上海' and 增值费用 is null");
        ResultSet resultSets = pup.executeQuery();
        while (resultSets.next())
        {
            String xuhao = resultSets.getString("序号");
            PreparedStatement pset = connection.prepareStatement("update " + endtable + " set `备注` = `备注`+'应该是退回件' where 序号 = " + xuhao);
            pset.executeUpdate();
            pset.close();
        }

    }
}
